<template>
  <div class="home-page">
    <!-- 英雄区域 -->
    <section class="hero-section">
      <div class="container">
        <div class="hero-content">
          <div class="hero-text">
            <h1 class="hero-title fade-in">
              引领数字化转型
              <span class="highlight">创新科技未来</span>
            </h1>
            <p class="hero-description fade-in">
              IKeySoft专注于为企业提供全方位的软件解决方案，
              助力企业实现数字化转型，提升核心竞争力
            </p>
            <div class="hero-actions fade-in">
              <el-button type="primary" size="large" @click="scrollToProducts">
                了解产品
              </el-button>
              <el-button size="large" @click="goToContact">
                联系我们
              </el-button>
            </div>
          </div>
          <div class="hero-image">
            <div class="hero-visual">
              <div class="floating-card" v-for="(item, index) in floatingItems" :key="index" :style="{ animationDelay: index * 0.2 + 's' }">
                <el-icon><component :is="item.icon" /></el-icon>
                <span>{{ item.text }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 核心数据指标 -->
    <section class="metrics-section">
      <div class="container">
        <div class="metrics-grid">
          <div class="metric-item" v-for="metric in metrics" :key="metric.label">
            <div class="metric-number">{{ metric.value }}</div>
            <div class="metric-label">{{ metric.label }}</div>
          </div>
        </div>
      </div>
    </section>

    <!-- 核心价值主张 -->
    <section class="values-section">
      <div class="container">
        <h2 class="section-title">核心价值主张</h2>
        <div class="values-grid">
          <div class="value-card" v-for="value in coreValues" :key="value.title">
            <div class="value-icon">
              <el-icon><component :is="value.icon" /></el-icon>
            </div>
            <h3 class="value-title">{{ value.title }}</h3>
            <p class="value-description">{{ value.description }}</p>
          </div>
        </div>
      </div>
    </section>

    <!-- 产品展示 -->
    <section class="products-section" ref="productsSection">
      <div class="container">
        <h2 class="section-title">核心产品</h2>
        <div class="products-grid">
          <div class="product-card" v-for="product in featuredProducts" :key="product.id">
            <div class="product-image">
              <img :src="product.image" :alt="product.name" />
            </div>
            <div class="product-content">
              <h3 class="product-name">{{ product.name }}</h3>
              <p class="product-description">{{ product.description }}</p>
              <div class="product-features">
                <span class="feature-tag" v-for="feature in product.features" :key="feature">
                  {{ feature }}
                </span>
              </div>
              <el-button type="primary" @click="goToProduct(product.id)">
                了解详情
              </el-button>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 客户案例 -->
    <section class="cases-section">
      <div class="container">
        <h2 class="section-title">成功案例</h2>
        <div class="cases-carousel">
          <el-carousel height="300px" :autoplay="true" :interval="5000">
            <el-carousel-item v-for="case_ in successCases" :key="case_.id">
              <div class="case-content">
                <div class="case-info">
                  <h3 class="case-title">{{ case_.title }}</h3>
                  <p class="case-description">{{ case_.description }}</p>
                  <div class="case-results">
                    <div class="result-item" v-for="result in case_.results" :key="result.label">
                      <span class="result-value">{{ result.value }}</span>
                      <span class="result-label">{{ result.label }}</span>
                    </div>
                  </div>
                </div>
                <div class="case-image">
                  <img :src="case_.image" :alt="case_.title" />
                </div>
              </div>
            </el-carousel-item>
          </el-carousel>
        </div>
      </div>
    </section>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import {
  TrendCharts,
  DataAnalysis,
  CloudyAndSunny,
  MobilePhone,
  Setting,
  Shield,
  Lightning,
  Trophy
} from '@element-plus/icons-vue'

const router = useRouter()
const productsSection = ref<HTMLElement>()

// 浮动元素
const floatingItems = [
  { icon: 'TrendCharts', text: '数据分析' },
  { icon: 'CloudyAndSunny', text: '云计算' },
  { icon: 'MobilePhone', text: '移动应用' },
  { icon: 'Setting', text: '系统集成' }
]

// 核心指标
const metrics = [
  { value: '500+', label: '服务客户' },
  { value: '1000+', label: '成功项目' },
  { value: '99.9%', label: '系统稳定性' },
  { value: '24/7', label: '技术支持' }
]

// 核心价值
const coreValues = [
  {
    icon: 'Lightning',
    title: '高效创新',
    description: '采用最新技术栈，快速响应业务需求，提供高效的解决方案'
  },
  {
    icon: 'Shield',
    title: '安全可靠',
    description: '企业级安全保障，多重数据保护机制，确保系统稳定运行'
  },
  {
    icon: 'Setting',
    title: '定制化服务',
    description: '深度理解客户需求，提供个性化定制开发和专业技术支持'
  },
  {
    icon: 'Trophy',
    title: '卓越品质',
    description: '严格的质量管控体系，持续优化产品性能，追求卓越品质'
  }
]

// 特色产品
const featuredProducts = [
  {
    id: 46,
    name: '企业管理系统',
    description: '全面的企业资源管理解决方案，提升管理效率',
    image: '/images/product-1.jpg',
    features: ['流程管理', '数据分析', '移动办公']
  },
  {
    id: 44,
    name: '数据分析平台',
    description: '智能数据分析与可视化平台，助力数据驱动决策',
    image: '/images/product-2.jpg',
    features: ['实时分析', '可视化', '预测模型']
  },
  {
    id: 43,
    name: '云计算服务',
    description: '弹性云计算解决方案，降低IT成本，提升业务敏捷性',
    image: '/images/product-3.jpg',
    features: ['弹性扩展', '高可用', '成本优化']
  }
]

// 成功案例
const successCases = [
  {
    id: 1,
    title: '某大型制造企业数字化转型',
    description: '通过实施企业管理系统，实现了生产流程的全面数字化管理',
    image: '/images/case-1.jpg',
    results: [
      { value: '30%', label: '效率提升' },
      { value: '50%', label: '成本降低' },
      { value: '99%', label: '准确率' }
    ]
  },
  {
    id: 2,
    title: '金融机构数据分析平台建设',
    description: '构建了完整的数据分析体系，提升了风险控制和决策能力',
    image: '/images/case-2.jpg',
    results: [
      { value: '40%', label: '风险降低' },
      { value: '60%', label: '决策速度' },
      { value: '95%', label: '客户满意度' }
    ]
  }
]

// 方法
const scrollToProducts = () => {
  productsSection.value?.scrollIntoView({ behavior: 'smooth' })
}

const goToContact = () => {
  router.push('/contactus')
}

const goToProduct = (productId: number) => {
  router.push(`/product?productId=${productId}`)
}
</script>

<style scoped>
.home-page {
  overflow-x: hidden;
}

/* 英雄区域 */
.hero-section {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.hero-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
}

.hero-text {
  color: white;
}

.hero-title {
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1.5rem;
}

.highlight {
  background: linear-gradient(45deg, #ffd700, #ffed4e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-description {
  font-size: 1.2rem;
  line-height: 1.6;
  margin-bottom: 2rem;
  opacity: 0.9;
}

.hero-actions {
  display: flex;
  gap: 1rem;
}

.hero-visual {
  position: relative;
  height: 400px;
}

.floating-card {
  position: absolute;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
  animation: float 3s ease-in-out infinite;
}

.floating-card:nth-child(1) { top: 20%; left: 10%; }
.floating-card:nth-child(2) { top: 40%; right: 20%; }
.floating-card:nth-child(3) { bottom: 30%; left: 20%; }
.floating-card:nth-child(4) { bottom: 10%; right: 10%; }

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

/* 指标区域 */
.metrics-section {
  padding: 4rem 0;
  background: white;
  margin-top: -2rem;
  position: relative;
  z-index: 2;
  border-radius: 2rem 2rem 0 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2rem;
  text-align: center;
}

.metric-item {
  padding: 2rem;
}

.metric-number {
  font-size: 3rem;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.metric-label {
  font-size: 1.1rem;
  color: #666;
  font-weight: 500;
}

/* 价值主张区域 */
.values-section {
  padding: 6rem 0;
  background: #f8fafc;
}

.values-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3rem;
}

.value-card {
  background: white;
  padding: 3rem;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  text-align: center;
  transition: all 0.3s ease;
}

.value-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.value-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  color: white;
  font-size: 2rem;
}

.value-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #333;
}

.value-description {
  color: #666;
  line-height: 1.6;
}

/* 产品区域 */
.products-section {
  padding: 6rem 0;
  background: white;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.product-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: all 0.3s ease;
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.product-image {
  height: 200px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-content {
  padding: 2rem;
}

.product-name {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #333;
}

.product-description {
  color: #666;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.product-features {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.feature-tag {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.9rem;
}

/* 案例区域 */
.cases-section {
  padding: 6rem 0;
  background: #f8fafc;
}

.case-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
  height: 100%;
  padding: 2rem;
}

.case-title {
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #333;
}

.case-description {
  color: #666;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.case-results {
  display: flex;
  gap: 2rem;
}

.result-item {
  text-align: center;
}

.result-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: #667eea;
  margin-bottom: 0.5rem;
}

.result-label {
  color: #666;
  font-size: 0.9rem;
}

.case-image {
  height: 250px;
  background: #ddd;
  border-radius: 12px;
  overflow: hidden;
}

.case-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .hero-content {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .values-grid {
    grid-template-columns: 1fr;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .hero-title {
    font-size: 2.5rem;
  }

  .products-grid {
    grid-template-columns: 1fr;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .case-content {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .hero-actions {
    flex-direction: column;
    align-items: center;
  }

  .case-results {
    justify-content: center;
  }
}
</style>